# eric7.MicroPython.Devices.PyBoardDevices

Module implementing the device interface class for PyBoard boards.

### Global Attributes

None

### Classes

PyBoardDevice | Class implementing the device for PyBoard boards.

### Functions

createDevice | Function to instantiate a MicroPython device object.

## PyBoardDevice

Class implementing the device for PyBoard boards.

### Derived from

BaseDevice

### Class Attributes

DeviceVolumeName
FlashInstructionsURL

### Class Methods

None

### Methods

PyBoardDevice | Constructor
__activateBootloader | Private slot to activate the bootloader and disconnect.
__createPyboardMenu | Private method to create the pyboard submenu.
__deviceVolumeMounted | Private method to check, if the device volume is mounted.
__dfuUtilAvailable | Private method to check the availability of dfu-util.
__findWorkspace | Private method to find the workspace directory.
__firmwareVersionResponse | Private slot handling the response of the latest version request.
__flashMicroPython | Private slot to flash a MicroPython firmware.
__listDfuCapableDevices | Private slot to list all DFU-capable devices.
__resetDevice | Private slot to reset the connected device.
__showDfuDisableInstructions | Private method to show some instructions to disable the DFU mode.
__showDfuEnableInstructions | Private method to show some instructions to enable the DFU mode.
__showFirmwareVersions | Private slot to show the firmware version of the connected device and the available firmware version.
__showFlashInstructions | Private slot to open the URL containing instructions for installing MicroPython on the pyboard.
_getSetTimeCode | Protected method to get the device code to set the time.
addDeviceMenuEntries | Public method to add device specific entries to the given menu.
canRunScript | Public method to determine, if a script can be executed.
canStartFileManager | Public method to determine, if a File Manager can be started.
canStartPlotter | Public method to determine, if a Plotter can be started.
canStartRepl | Public method to determine, if a REPL can be started.
deviceName | Public method to get the name of the device.
forceInterrupt | Public method to determine the need for an interrupt when opening the serial connection.
getDocumentationUrl | Public method to get the device documentation URL.
getFirmwareUrl | Public method to get the device firmware download URL.
getWorkspace | Public method to get the workspace directory.
hasFlashMenuEntry | Public method to check, if the device has its own flash menu entry.
runScript | Public method to run the given Python script.
setButtons | Public method to enable the supported action buttons.
supportsLocalFileAccess | Public method to indicate file access via a local directory.

### Static Methods

None

#### PyBoardDevice (Constructor)

PyBoardDevice(microPythonWidget, deviceType, parent=None)

Constructor

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
parent (QObject)
  reference to the parent object

#### PyBoardDevice.__activateBootloader

__activateBootloader()

Private slot to activate the bootloader and disconnect.

#### PyBoardDevice.__createPyboardMenu

__createPyboardMenu()

Private method to create the pyboard submenu.

#### PyBoardDevice.__deviceVolumeMounted

__deviceVolumeMounted()

Private method to check, if the device volume is mounted.

Return:
  flag indicated a mounted device

Return Type:
  bool

#### PyBoardDevice.__dfuUtilAvailable

__dfuUtilAvailable()

Private method to check the availability of dfu-util.

Return:
  flag indicating the availability of dfu-util

Return Type:
  bool

#### PyBoardDevice.__findWorkspace

__findWorkspace(silent=False)

Private method to find the workspace directory.

silent (bool)
  flag indicating silent operations

Return:
  workspace directory used for saving files

Return Type:
  str

#### PyBoardDevice.__firmwareVersionResponse

__firmwareVersionResponse(reply)

Private slot handling the response of the latest version request.

reply (QNetworkReply)
  reference to the reply object

#### PyBoardDevice.__flashMicroPython

__flashMicroPython()

Private slot to flash a MicroPython firmware.

#### PyBoardDevice.__listDfuCapableDevices

__listDfuCapableDevices()

Private slot to list all DFU-capable devices.

#### PyBoardDevice.__resetDevice

__resetDevice()

Private slot to reset the connected device.

#### PyBoardDevice.__showDfuDisableInstructions

__showDfuDisableInstructions()

Private method to show some instructions to disable the DFU mode.

#### PyBoardDevice.__showDfuEnableInstructions

__showDfuEnableInstructions(flash=True)

Private method to show some instructions to enable the DFU mode.

flash (bool)
  flag indicating to show a warning message for flashing

Return:
  flag indicating OK to continue or abort

Return Type:
  bool

#### PyBoardDevice.__showFirmwareVersions

__showFirmwareVersions()

Private slot to show the firmware version of the connected device and the available firmware version.

#### PyBoardDevice.__showFlashInstructions

__showFlashInstructions()

Private slot to open the URL containing instructions for installing MicroPython on the pyboard.

#### PyBoardDevice._getSetTimeCode

_getSetTimeCode()

Protected method to get the device code to set the time.

Note: This method must be implemented in the various device specific subclasses.

Return:
  code to be executed on the connected device to set the time

Return Type:
  str

#### PyBoardDevice.addDeviceMenuEntries

addDeviceMenuEntries(menu)

Public method to add device specific entries to the given menu.

menu (QMenu)
  reference to the context menu

#### PyBoardDevice.canRunScript

canRunScript()

Public method to determine, if a script can be executed.

Return:
  tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### PyBoardDevice.canStartFileManager

canStartFileManager()

Public method to determine, if a File Manager can be started.

Return:
  tuple containing a flag indicating it is safe to start a File Manager and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### PyBoardDevice.canStartPlotter

canStartPlotter()

Public method to determine, if a Plotter can be started.

Return:
  tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### PyBoardDevice.canStartRepl

canStartRepl()

Public method to determine, if a REPL can be started.

Return:
  tuple containing a flag indicating it is safe to start a REPL and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### PyBoardDevice.deviceName

deviceName()

Public method to get the name of the device.

Return:
  name of the device

Return Type:
  str

#### PyBoardDevice.forceInterrupt

forceInterrupt()

Public method to determine the need for an interrupt when opening the serial connection.

Return:
  flag indicating an interrupt is needed

Return Type:
  bool

#### PyBoardDevice.getDocumentationUrl

getDocumentationUrl()

Public method to get the device documentation URL.

Return:
  documentation URL of the device

Return Type:
  str

#### PyBoardDevice.getFirmwareUrl

getFirmwareUrl()

Public method to get the device firmware download URL.

Return:
  firmware download URL of the device

Return Type:
  str

#### PyBoardDevice.getWorkspace

getWorkspace(silent=False)

Public method to get the workspace directory.

silent (bool)
  flag indicating silent operations

Return:
  workspace directory used for saving files

Return Type:
  str

#### PyBoardDevice.hasFlashMenuEntry

hasFlashMenuEntry()

Public method to check, if the device has its own flash menu entry.

Return:
  flag indicating a specific flash menu entry

Return Type:
  bool

#### PyBoardDevice.runScript

runScript(script)

Public method to run the given Python script.

script (str)
  script to be executed

#### PyBoardDevice.setButtons

setButtons()

Public method to enable the supported action buttons.

#### PyBoardDevice.supportsLocalFileAccess

supportsLocalFileAccess()

Public method to indicate file access via a local directory.

Return:
  flag indicating file access via local directory

Return Type:
  bool

Up

## createDevice

createDevice(microPythonWidget, deviceType, _vid, _pid, _boardName, _serialNumber)

Function to instantiate a MicroPython device object.

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
_vid (int)
  vendor ID (unused)
_pid (int)
  product ID (unused)
_boardName (str)
  name of the board (unused)
_serialNumber (str)
  serial number of the board (unused)

Return:
  reference to the instantiated device object

Return Type:
  PyBoardDevice

Up